<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<form>
			<div>
				<input type="text" name="account" placeholder="请输入账号" />
			</div>
			<div>
				<input type="password" name="password" placeholder="请输入密码" />
			</div>
			<div>
				<button type="button" onclick="login()">登录</button>
				<a href="03-注册.html">注册</a>
			</div>
		</form>
		<script type="text/javascript">
			function login() {
				let input_account = document.getElementsByName("account")[0];
				let input_password = document.getElementsByName("password")[0];
				
				let account = input_account.value;
				let password = input_password.value;
				
				let users = JSON.parse(localStorage.getItem("users"));
				for(let item of users) {
					if(account === item.account && password === item.password) {
						console.log("登录成功");
						return;
					}
				}
				
				console.log("账号或密码错误");
			}
		</script>
	</body>
</html>
